package com.sgb.kjwl.view.ui.fragment.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.EmptyViewBinding;

public class NullFragment extends AppLazyFragment {

    EmptyViewBinding binding;
    private FinishFragment finishFragment;
    private int position;

    public void setFinishFragment(FinishFragment finishFragment) {
        this.finishFragment = finishFragment;
    }

    public static NullFragment newInstance(int position) {
        NullFragment fragment = new NullFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("position", position);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.empty_view, container, false);
        position = getArguments().getInt("position",0);
        return binding.getRoot();
    }

    @Override
    protected void onLazyLoad() {
        if (finishFragment != null){
            if (position == 4){
                finishFragment.finishFragment(position);
            }else if (position == 5){
                finishFragment.finishFragment(position);
            }else if (position == 6){
                finishFragment.finishFragment(position);
            }
        }
    }

    interface FinishFragment{
        void finishFragment(int position);
    }
}
